package cn.yangliu.springbatch.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * the type of springbatch
 *
 * <p>
 * .
 *
 * @author 杨柳
 * @date 2021-07-12
 */
@Entity
@Table(name = "t_user")
@EntityListeners(AuditingEntityListener.class)
public class User implements Serializable {


    private static final long serialVersionUID = -6464394201807669429L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String username;

    private Integer age;

    private String address;

    private String job;

    public User() {
    }

    public User(String username, Integer age, String address, String job) {
        this.username = username;
        this.age = age;
        this.address = address;
        this.job = job;
    }

    @CreatedDate
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @LastModifiedDate
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * instance member witch named id‘s getter
     * <p>
     * for get field witch named id’s value
     *
     * @return id
     */
    public Long getId() {
        return id;
    }

    /**
     * instance member witch named id's setter
     * for set field witch named id's value
     *
     * @param id id
     */
    public User setId(Long id) {
        this.id = id;
        return this;
    }

    /**
     * instance member witch named username‘s getter
     * <p>
     * for get field witch named username’s value
     *
     * @return username
     */
    public String getUsername() {
        return username;
    }

    /**
     * instance member witch named username's setter
     * for set field witch named username's value
     *
     * @param username username
     */
    public User setUsername(String username) {
        this.username = username;
        return this;
    }

    /**
     * instance member witch named age‘s getter
     * <p>
     * for get field witch named age’s value
     *
     * @return age
     */
    public Integer getAge() {
        return age;
    }

    /**
     * instance member witch named age's setter
     * for set field witch named age's value
     *
     * @param age age
     */
    public User setAge(Integer age) {
        this.age = age;
        return this;
    }

    /**
     * instance member witch named address‘s getter
     * <p>
     * for get field witch named address’s value
     *
     * @return address
     */
    public String getAddress() {
        return address;
    }

    /**
     * instance member witch named address's setter
     * for set field witch named address's value
     *
     * @param address address
     */
    public User setAddress(String address) {
        this.address = address;
        return this;
    }

    /**
     * instance member witch named job‘s getter
     * <p>
     * for get field witch named job’s value
     *
     * @return job
     */
    public String getJob() {
        return job;
    }

    /**
     * instance member witch named job's setter
     * for set field witch named job's value
     *
     * @param job job
     */
    public User setJob(String job) {
        this.job = job;
        return this;
    }


    /**
     * instance member witch named createTime‘s getter
     * <p>
     * for get field witch named createTime’s value
     *
     * @return createTime
     */
    public LocalDateTime getCreateTime() {
        return createTime;
    }

    /**
     * instance member witch named createTime's setter
     * for set field witch named createTime's value
     *
     * @param createTime createTime
     */
    public User setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
        return this;
    }

    /**
     * instance member witch named updateTime‘s getter
     * <p>
     * for get field witch named updateTime’s value
     *
     * @return updateTime
     */
    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    /**
     * instance member witch named updateTime's setter
     * for set field witch named updateTime's value
     *
     * @param updateTime updateTime
     */
    public User setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
        return this;
    }

    @Override
    public String toString() {
        return "User{" + "id=" + id + ", username='" + username + '\'' + ", age=" + age + ", address='" + address + '\'' + ", job='" + job + '\'' + ", createTime=" + createTime + ", updateTime=" + updateTime + '}';
    }
}
